package com.cyou.nad.datastore.exception;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.cyou.nad.datastore.ColType;

/**
 * �����Բ�ƥ���쳣 
 * @author lzm 
 */
public class ColumnTypeNotMatchException extends RuntimeException {

	private static final long serialVersionUID = 3521719979822164841L;
	private ColType want;
	private ColType butIs;
	private int col;
	private String colName;
	private String msg;
	public ColumnTypeNotMatchException() {
		super();
	}

	public ColumnTypeNotMatchException(String message) {
		super();
		this.msg=message;
	}

	public ColumnTypeNotMatchException(Throwable cause) {
		super(cause);
	}

	public ColumnTypeNotMatchException(ColType want, ColType butIs) {
		this();
		this.want = want;
		this.butIs = butIs;
	}

	public ColumnTypeNotMatchException(ColType want, ColType butIs, int col) {
		this(want, butIs);
		this.col = col;
	}

	public ColumnTypeNotMatchException(ColType want, ColType butIs, String colName) {
		this(want, butIs);
		this.colName = colName;
	}

	@Override
	public String getMessage() {
		return toString();
	}

	@Override
	public String toString() {
		if(StringUtils.isBlank(msg))
			return msg;
		ToStringBuilder builder = new ToStringBuilder(this);
		builder.append("�����type", want).append("���Ǹ��type", butIs).append("colNum", col).append("colName", colName)
				.append(super.getMessage());
		return builder.toString();
	}

}